﻿using Md.Api.Model;
using Md.Api.Model.Manage.SysDictType.Request;
using Md.Api.Service.Manage.SysDictType;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 系统字典类型
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/system/dict/type")]
public class SysDictTypeController : ControllerBase
{
    /// <summary>
    /// 通过字典编号删除系统字典类型服务
    /// </summary>
    public DeleteSysDictTypeByDictIdService deleteSysDictTypeByDictIdService { get; set; }
    /// <summary>
    /// 通过字典编号删除系统字典类型
    /// </summary>
    /// <param name="dictIds">字典编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{dictIds}")]
    public async Task<ResponseMessageModel> DeleteSysDictTypeByDictId(string dictIds, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteSysDictTypeByDictIdModel();

        model.DictIds = dictIds;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteSysDictTypeByDictIdService.Execute(model));
    }

    /// <summary>
    /// 添加系统字典类型服务
    /// </summary>
    public InsertSysDictTypeService insertSysDictTypeService { get; set; }
    /// <summary>
    /// 添加系统字典类型
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertSysDictType([FromBody] RequestInsertSysDictTypeModel model)
    {
        return await Task.Run(() => insertSysDictTypeService.Execute(model));
    }

    /// <summary>
    /// 通过字典编号更新系统字典类型服务
    /// </summary>
    public UpdateSysDictTypeByDictIdService updateSysDictTypeByDictIdService { get; set; }
    /// <summary>
    /// 通过字典编号更新系统字典类型
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateSysDictTypeByDictId([FromBody] RequestUpdateSysDictTypeByDictIdModel model)
    {
        return await Task.Run(() => updateSysDictTypeByDictIdService.Execute(model));
    }

    /// <summary>
    /// 通过字典编号获取字典类型服务
    /// </summary>
    public GetSysDictTypeByDictIdService getSysDictTypeByDictIdService { get; set; }
    /// <summary>
    /// 通过字典编号获取字典类型
    /// </summary>
    /// <param name="dictId">字典编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{dictId}")]
    public async Task<ResponseMessageModel> GetSysDictTypeByDictId(long dictId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetSysDictTypeByDictIdModel();

        model.DictId = dictId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getSysDictTypeByDictIdService.Execute(model));
    }

    /// <summary>
    /// 获取系统字典类型列表服务
    /// </summary>
    public GetSysDictTypeListService getSysDictTypeListService { get; set; }
    /// <summary>
    /// 获取系统字典类型列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetSysDictTypeList([FromBody] RequestGetSysDictTypeListModel model)
    {
        return await Task.Run(() => getSysDictTypeListService.Execute(model));
    }

    /// <summary>
    /// 分页获取系统字典类型列表服务
    /// </summary>
    public GetSysDictTypePageListService getSysDictTypePageListService { get; set; }
    /// <summary>
    /// 分页获取系统字典类型列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetSysDictTypePageList([FromBody] RequestGetSysDictTypePageListModel model)
    {
        return await Task.Run(() => getSysDictTypePageListService.Execute(model));
    }
}

